#if !defined(BASIC_WINDOWS_H__)
#    define BASIC_WINDOWS_H__

#    pragma once

#    include "TitleBar.h"

#    include <QDialog>
#    include <QToolTip>

class BasicWindows : public QDialog {
    Q_OBJECT

public:
    BasicWindows(QWidget* parent = nullptr);
    virtual ~BasicWindows();

public:
    // 加载样式表
    void loadStyleSheet(const QString& sheetName);

    // 获取圆头像
    QPixmap getRoundImage(const QPixmap& src, QPixmap& mask, QSize masksize = QSize(0, 0));

private:
    void initBackGroundColor();

protected:
    virtual void paintEvent(QPaintEvent* event);
    virtual void mouseMoveEvent(QMouseEvent* event);
    virtual void mousePressEvent(QMouseEvent* event);
    virtual void mouseReleaseEvent(QMouseEvent* event);

protected:
    void initTitleBar(ButtonType buttonType = MIN_BUTTON);
    void initTitleBar(TitleBar* titlebar);
    void setTitleBarTitle(const QString& title, const QString& icon);

    // 保存、获取窗口最大化前窗口的位置及大小
    void  saveRestoreInfo(const QRect& rect);
    QRect getRestoreInfo();

    void moveMouseToPosition(const QPoint& position);

public slots:
    void onShowClose(bool);
    void onShowMin(bool);
    void onShowHide(bool);
    void onShowNormal(bool);
    void onShowQuit(bool);
    void onShowMax();
    void onShowRestore();
    void onShowRestore(const QRect& rect);
    void onSignalSkinChanged(const QColor& color);  // 皮肤改变

    void onButtonMinClicked();
    void onButtonMaxClicked();
    void onButtonRestoreClicked();
    void onButtonCloseClicked();

    void         drawShadow();
    virtual void setContentMargin(int margin);

signals:
    void signalWindowRestore();

protected:
    void showTipText(QString text, QPoint point, int time = 2000);
    void showTipText(QString text, int time = 2000);
protected:
    QPoint    mousePoint;
    bool      mousePressed;
    QColor    colorBackGround;
    QString   styleName;
    TitleBar* titleBar = nullptr;

    // 最大化还原按钮变量（用于保存窗体的位置及大小）
    // QPoint restorePos;
    // QSize restoreSize;
    QRect restoreRect;
    bool  isMax = false;
};

#endif  // BASIC_WINDOWS_H__
